function timistemicalc(age,dm, sbp, hr, killip, weight, antst, time){

var timiscore=0;
var mortality ="0.8% risk of all-cause mortality at 30 days.";

if (dm){dm=1;}else{dm=0;}
if (sbp){sbp=3;}else{sbp=0;}
if (hr){hr=2;}else{hr=0;}
if (killip){killip=2;}else{killip=0;}
if (weight){weight=1;}else{weight=0;}
if (antst){antst=1;}else{antst=0;}
if (time){time=1;}else{time=0;}

timiscore= age + dm + sbp + hr + killip + weight + antst + time;


if (timiscore ==1) {mortality = "1.6% risk of all-cause mortality at 30 days.";}
if (timiscore ==2) {mortality = "2.2% risk of all-cause mortality at 30 days.";}
if (timiscore ==3) {mortality = "4.4% risk of all-cause mortality at 30 days.";}
if (timiscore ==4) {mortality = "7.3% risk of all-cause mortality at 30 days.";}
if (timiscore ==5) {mortality = "12.4% risk of all-cause mortality at 30 days.";}
if (timiscore ==6) {mortality = "16.1% risk of all-cause mortality at 30 days.";}
if (timiscore ==7) {mortality = "23.4% risk of all-cause mortality at 30 days.";}
if (timiscore ==8) {mortality = "26.8% risk of all-cause mortality at 30 days.";}
if (timiscore > 8) {mortality = "35.9% risk of all-cause mortality at 30 days.";}



return {
			 timiscore:timiscore,
			 mortality:mortality
	};		 
}


var killipdef="Killip Classes<br /><ul><li>II   : Bilateral crackles in up to 50% of lung fields, isolated S3</li> <li>III  : Bilateral crackles in all lung fields, acute Mitral Regurgitation</li>	  	 <li>IV : Cardiogenic shock - Pulmonary Edema, Systolic BP <90, poor urine output</li> </ul>";
function ref(){
// display reference
 return "<a href='http://circ.ahajournals.org/cgi/content/abstract/102/17/2031'>Morrow DA et al. Circulation 2000;102:2031-7</a>";
}

function help() {
	return killipdef;
}
